package net.xiduth.game.player.dialogues.auto;

import net.xiduth.game.player.dialogues.Dialogue;

/**
 * 
 * @author Oracle
 * 
 * Handles Trivia rewards.
 *
 */
public class TriviaRewards extends Dialogue {


	@Override
	public void start() {
		sendOptionsDialogue("Select an Option", "How many points do I have?", "I would like to exchange my points.", "How do I get points?", "I would like to access my bank account.", "Never mind.");
		stage = -1;
	}

	@Override
	public void run(int interfaceId, int option) {
		switch(stage) {
		case -1:
			sendOptionsDialogue("Select an Option", "How many points do I have?", "I would like to exchange my points.", "How do I get points?", "I would like to access my bank account.", "Never mind.");
			stage = 0;
			break;
		case 0:
			switch(option) {
			case OPTION_1:
				sendDialogue("You currently have " + player.getTriviaPoints() + " Trivia points.");
				stage = -1;
				break;
			case OPTION_2:
				sendOptionsDialogue("Trivia Rewards - Page 1", "Agile top (5000 pts.)", "Agile legs (5000 pts.)", "Magic whistle (100 pts.)" , "250x Stardust (200 pts.)", "Never mind.");
				stage = 4;
				break;
			case OPTION_3:
				sendDialogue("Simple, type ::answer when a trivia question appears!");
				stage = -1;
				break;
			case OPTION_4:
				player.getBank().openBank();
				player.getInterfaceManager().closeChatBoxInterface();
				break;
			case OPTION_5:
				player.getInterfaceManager().closeChatBoxInterface();
				break;
			}
			break;
		case 3:
			end();
			break;
		case 4:
			switch(option) {
		case OPTION_1:
				if (player.getTriviaPoints() >= 5000) {
				player.getBank().addItem(14936, 1, true);
				player.setTriviaPoints(player.getTriviaPoints()
						- 5000);
				player.getInterfaceManager().closeChatBoxInterface();
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 14936, 1);
				player.getPackets().sendIComponentText(1189, 4, "The item has been added to your bank.");
				stage = 3;
				}else{
				sendDialogue("You need 5000 points to buy this item." );
				stage = 3;
				}
				break;
		case OPTION_2:
			if (player.getTriviaPoints() >= 5000) {
			player.getBank().addItem(14938, 1, true);
			player.setTriviaPoints(player.getTriviaPoints()
					- 5000);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 14938, 1);
			player.getPackets().sendIComponentText(1189, 4, "The items have been added to your bank.");
			stage = 3;
			}else{
			sendDialogue("You need 25 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_3:
			if (player.getTriviaPoints() >= 100) {
			player.getBank().addItem(16, 1, true);
			player.setTriviaPoints(player.getTriviaPoints()
					- 100);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 8782, 1);
			player.getPackets().sendIComponentText(1189, 4, "The item has been added to your bank.");
			stage = 3;
			}else{
			sendDialogue("You need 100 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_4:
			if (player.getTriviaPoints() >= 200) {
			player.getBank().addItem(13727, 250, true);
			player.setTriviaPoints(player.getTriviaPoints()
					- 200);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 13727, 1);
			player.getPackets().sendIComponentText(1189, 4, "The items have been added to your bank.");
			stage = 3;
			}else{
			sendDialogue("You need 200 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_5:
			player.getInterfaceManager().closeChatBoxInterface();
			break;
		default:
			end();
			break;
		}}}

	@Override
	public void finish() {

	}

}
